package com.github.east196.terminator.xtend.rest;

import com.github.east196.terminator.xtend.meta.DocMetaParser;
import com.github.east196.terminator.xtend.model.Field;
import com.github.east196.terminator.xtend.model.GeneResult;
import com.github.east196.terminator.xtend.model.Project;
import com.github.east196.terminator.xtend.model.Record;
import com.github.east196.terminator.xtend.model.Three;
import com.google.common.base.CaseFormat;
import com.google.common.base.Objects;
import java.util.List;
import java.util.function.Consumer;
import javax.annotation.Generated;
import org.boon.Boon;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.InputOutput;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;

@SuppressWarnings("all")
@Generated("org.eclipse.xtend.core.compiler.XtendGenerator")
public class Heyang2019 {
  public static void main(final String[] args) {
    DocMetaParser _docMetaParser = new DocMetaParser();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("D:\\hyyy\\杂件\\统一数据文档 Test.doc");
    final Function1<Three, Boolean> _function = (Three three) -> {
      String _trim = three.getRecord().getGeneOk().trim();
      return Boolean.valueOf(Objects.equal(_trim, ""));
    };
    final Consumer<Three> _function_1 = (Three three) -> {
      InputOutput.<Integer>println(Integer.valueOf(111));
      Heyang2019.geneAll(three);
    };
    IterableExtensions.<Three>filter(_docMetaParser.action(_builder.toString()), _function).forEach(_function_1);
  }
  
  public static Valid toValid(final String validStr) {
    return Valid.from(validStr);
  }
  
  public static String toJson(final Valid valid) {
    return Boon.toPrettyJson(valid);
  }
  
  public static void geneAll(final Three three) {
    Heyang2019.gene(three, "entity").copy();
    Heyang2019.gene(three, "crudservice").copy();
    Heyang2019.gene(three, "crudserviceimpl").copy();
    Heyang2019.gene(three, "service").copy();
    Heyang2019.gene(three, "serviceimpl").copy();
    Heyang2019.gene(three, "dao").copy();
    Heyang2019.gene(three, "customdao").copy();
    Heyang2019.gene(three, "customdaoimpl").copy();
    Heyang2019.gene(three, "controller").copy();
    Heyang2019.gene(three, "coustomcontroller").copy();
    Heyang2019.gene(three, "restcli").copy();
  }
  
  public static GeneResult gene(final Three three, final String type) {
    Project project = three.getProject();
    Record record = three.getRecord();
    List<Field> fields = three.getFields();
    final String javaPath = IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(project.getRoot().split("\\."))), "\\");
    String packageName = StringExtensions.toFirstLower(record.getName());
    CharSequence content = "";
    CharSequence path = "";
    if (type != null) {
      switch (type) {
        case "entity":
          content = Heyang2019.entity(project, record, fields);
          StringConcatenation _builder = new StringConcatenation();
          String _path = project.getPath();
          _builder.append(_path);
          _builder.append("\\src\\main\\java\\");
          _builder.append(javaPath);
          _builder.append("\\");
          _builder.append(packageName);
          _builder.append("\\");
          String _firstUpper = StringExtensions.toFirstUpper(record.getName());
          _builder.append(_firstUpper);
          _builder.append(".java");
          path = _builder;
          break;
        case "dao":
          content = Heyang2019.dao(project, record, fields);
          StringConcatenation _builder_1 = new StringConcatenation();
          String _path_1 = project.getPath();
          _builder_1.append(_path_1);
          _builder_1.append("\\src\\main\\java\\");
          _builder_1.append(javaPath);
          _builder_1.append("\\");
          _builder_1.append(packageName);
          _builder_1.append("\\");
          String _firstUpper_1 = StringExtensions.toFirstUpper(record.getName());
          _builder_1.append(_firstUpper_1);
          _builder_1.append("Repository.java");
          path = _builder_1;
          break;
        case "customdao":
          content = Heyang2019.customdao(project, record, fields);
          StringConcatenation _builder_2 = new StringConcatenation();
          String _path_2 = project.getPath();
          _builder_2.append(_path_2);
          _builder_2.append("\\src\\main\\java\\");
          _builder_2.append(javaPath);
          _builder_2.append("\\");
          _builder_2.append(packageName);
          _builder_2.append("\\Customized");
          String _firstUpper_2 = StringExtensions.toFirstUpper(record.getName());
          _builder_2.append(_firstUpper_2);
          _builder_2.append("Repository.java");
          path = _builder_2;
          break;
        case "customdaoimpl":
          content = Heyang2019.customdaoimpl(project, record, fields);
          StringConcatenation _builder_3 = new StringConcatenation();
          String _path_3 = project.getPath();
          _builder_3.append(_path_3);
          _builder_3.append("\\src\\main\\java\\");
          _builder_3.append(javaPath);
          _builder_3.append("\\");
          _builder_3.append(packageName);
          _builder_3.append("\\Customized");
          String _firstUpper_3 = StringExtensions.toFirstUpper(record.getName());
          _builder_3.append(_firstUpper_3);
          _builder_3.append("RepositoryImpl.java");
          path = _builder_3;
          break;
        case "controller":
          content = Heyang2019.controller(project, record, fields);
          StringConcatenation _builder_4 = new StringConcatenation();
          String _path_4 = project.getPath();
          _builder_4.append(_path_4);
          _builder_4.append("\\src\\main\\java\\");
          _builder_4.append(javaPath);
          _builder_4.append("\\");
          _builder_4.append(packageName);
          _builder_4.append("\\");
          String _firstUpper_4 = StringExtensions.toFirstUpper(record.getName());
          _builder_4.append(_firstUpper_4);
          _builder_4.append("Controller.java");
          path = _builder_4;
          break;
        case "restcli":
          content = Heyang2019.restcli(project, record, fields);
          StringConcatenation _builder_5 = new StringConcatenation();
          String _path_5 = project.getPath();
          _builder_5.append(_path_5);
          _builder_5.append("\\src\\main\\java\\");
          _builder_5.append(javaPath);
          _builder_5.append("\\");
          _builder_5.append(packageName);
          _builder_5.append("\\");
          String _firstUpper_5 = StringExtensions.toFirstUpper(record.getName());
          _builder_5.append(_firstUpper_5);
          _builder_5.append("Cli.java");
          path = _builder_5;
          break;
        case "service":
          content = Heyang2019.Service(project, record, fields);
          StringConcatenation _builder_6 = new StringConcatenation();
          String _path_6 = project.getPath();
          _builder_6.append(_path_6);
          _builder_6.append("\\src\\main\\java\\");
          _builder_6.append(javaPath);
          _builder_6.append("\\");
          _builder_6.append(packageName);
          _builder_6.append("\\");
          String _firstUpper_6 = StringExtensions.toFirstUpper(record.getName());
          _builder_6.append(_firstUpper_6);
          _builder_6.append("Service.java");
          path = _builder_6;
          break;
        case "serviceimpl":
          content = Heyang2019.ServiceImpl(project, record, fields);
          StringConcatenation _builder_7 = new StringConcatenation();
          String _path_7 = project.getPath();
          _builder_7.append(_path_7);
          _builder_7.append("\\src\\main\\java\\");
          _builder_7.append(javaPath);
          _builder_7.append("\\");
          _builder_7.append(packageName);
          _builder_7.append("\\");
          String _firstUpper_7 = StringExtensions.toFirstUpper(record.getName());
          _builder_7.append(_firstUpper_7);
          _builder_7.append("ServiceImpl.java");
          path = _builder_7;
          break;
        case "crudservice":
          content = Heyang2019.CrudService(project, record, fields);
          StringConcatenation _builder_8 = new StringConcatenation();
          String _path_8 = project.getPath();
          _builder_8.append(_path_8);
          _builder_8.append("\\src\\main\\java\\");
          _builder_8.append(javaPath);
          _builder_8.append("\\");
          _builder_8.append(packageName);
          _builder_8.append("\\");
          String _firstUpper_8 = StringExtensions.toFirstUpper(record.getName());
          _builder_8.append(_firstUpper_8);
          _builder_8.append("CrudService.java");
          path = _builder_8;
          break;
        case "crudserviceimpl":
          content = Heyang2019.CrudServiceImpl(project, record, fields);
          StringConcatenation _builder_9 = new StringConcatenation();
          String _path_9 = project.getPath();
          _builder_9.append(_path_9);
          _builder_9.append("\\src\\main\\java\\");
          _builder_9.append(javaPath);
          _builder_9.append("\\");
          _builder_9.append(packageName);
          _builder_9.append("\\");
          String _firstUpper_9 = StringExtensions.toFirstUpper(record.getName());
          _builder_9.append(_firstUpper_9);
          _builder_9.append("CrudServiceImpl.java");
          path = _builder_9;
          break;
        case "coustomcontroller":
          content = Heyang2019.CoustomCon1troller(project, record, fields);
          StringConcatenation _builder_10 = new StringConcatenation();
          String _path_10 = project.getPath();
          _builder_10.append(_path_10);
          _builder_10.append("\\src\\main\\java\\");
          _builder_10.append(javaPath);
          _builder_10.append("\\");
          _builder_10.append(packageName);
          _builder_10.append("\\");
          String _firstUpper_10 = StringExtensions.toFirstUpper(record.getName());
          _builder_10.append(_firstUpper_10);
          _builder_10.append("CoustomController.java");
          path = _builder_10;
          break;
        default:
          {
            content = Heyang2019.entity(three.getProject(), three.getRecord(), three.getFields());
            StringConcatenation _builder_11 = new StringConcatenation();
            String _path_11 = project.getPath();
            _builder_11.append(_path_11);
            _builder_11.append("\\src\\main\\java\\");
            _builder_11.append(javaPath);
            _builder_11.append("\\");
            _builder_11.append(packageName);
            _builder_11.append("\\");
            String _firstUpper_11 = StringExtensions.toFirstUpper(record.getName());
            _builder_11.append(_firstUpper_11);
            _builder_11.append(".java");
            path = _builder_11;
          }
          break;
      }
    } else {
      {
        content = Heyang2019.entity(three.getProject(), three.getRecord(), three.getFields());
        StringConcatenation _builder_11 = new StringConcatenation();
        String _path_11 = project.getPath();
        _builder_11.append(_path_11);
        _builder_11.append("\\src\\main\\java\\");
        _builder_11.append(javaPath);
        _builder_11.append("\\");
        _builder_11.append(packageName);
        _builder_11.append("\\");
        String _firstUpper_11 = StringExtensions.toFirstUpper(record.getName());
        _builder_11.append(_firstUpper_11);
        _builder_11.append(".java");
        path = _builder_11;
      }
    }
    return new GeneResult(content, path);
  }
  
  public static CharSequence CoustomCon1troller(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      final String basePackageName = project.getRoot();
      String packageName = StringExtensions.toFirstLower(record.getName());
      String klassType = StringExtensions.toFirstUpper(record.getName());
      String _firstUpper = StringExtensions.toFirstUpper(record.getName());
      String serviceType = (_firstUpper + "Service");
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      _builder.append(packageName);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("import org.slf4j.Logger;");
      _builder.newLine();
      _builder.append("import org.slf4j.LoggerFactory;");
      _builder.newLine();
      _builder.append("import io.swagger.annotations.Api;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.RestController;");
      _builder.newLine();
      _builder.append("import org.springframework.beans.factory.annotation.Autowired;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("@Api(\"自定义");
      String _label = record.getLabel();
      _builder.append(_label);
      _builder.append("管理接口\")");
      _builder.newLineIfNotEmpty();
      _builder.append("@RestController");
      _builder.newLine();
      _builder.append("public class ");
      _builder.append(klassType);
      _builder.append("CoustomController {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("private static final Logger LOGGER = LoggerFactory.getLogger(");
      _builder.append(klassType, "\t\t");
      _builder.append("Controller.class);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("@Autowired");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("private ");
      _builder.append(serviceType, "\t\t");
      _builder.append(" ");
      String _firstLower = StringExtensions.toFirstLower(serviceType);
      _builder.append(_firstLower, "\t\t");
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  public static CharSequence ServiceImpl(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      String klassType = StringExtensions.toFirstUpper(record.getName());
      final String basePackageName = project.getRoot();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      String _firstLower = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("import org.springframework.stereotype.Service;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("@Service");
      _builder.newLine();
      _builder.append("public class ");
      _builder.append(klassType);
      _builder.append("ServiceImpl extends ");
      _builder.append(klassType);
      _builder.append("CrudServiceImpl implements ");
      _builder.append(klassType);
      _builder.append("Service {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  public static CharSequence Service(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      String klassType = StringExtensions.toFirstUpper(record.getName());
      final String basePackageName = project.getRoot();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      String _firstLower = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("public interface ");
      _builder.append(klassType);
      _builder.append("Service extends ");
      _builder.append(klassType);
      _builder.append("CrudService{");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  public static CharSequence CrudService(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      String[] _split = project.getRoot().split("\\.");
      int _length = project.getRoot().split("\\.").length;
      int _minus = (_length - 2);
      final String commonPackageName = IterableExtensions.join(((List<String>)Conversions.doWrapArray(_split)).subList(0, _minus), ".");
      String klassType = StringExtensions.toFirstUpper(record.getName());
      final String basePackageName = project.getRoot();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      String _firstLower = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.append("import java.util.List;");
      _builder.newLine();
      _builder.append("import java.util.Map;");
      _builder.newLine();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.vo.DataResponse;");
      _builder.newLineIfNotEmpty();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.vo.Response;");
      _builder.newLineIfNotEmpty();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.vo.TableResult;");
      _builder.newLineIfNotEmpty();
      _builder.append("import org.springframework.data.jpa.domain.Specification;");
      _builder.newLine();
      _builder.append("public interface ");
      _builder.append(klassType);
      _builder.append("CrudService{");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("public List<");
      _builder.append(klassType, "\t");
      _builder.append("> findAll(Specification<");
      _builder.append(klassType, "\t");
      _builder.append("> spec);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("public TableResult<List<");
      _builder.append(klassType, "\t");
      _builder.append(">> findAll(Integer pageNo,Integer pageSize, Map<String, String> queryMap);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("public DataResponse<");
      _builder.append(klassType, "\t");
      _builder.append("> save(");
      _builder.append(klassType, "\t");
      _builder.append(" ");
      String _firstLower_1 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_1, "\t");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("public DataResponse<");
      _builder.append(klassType, "\t");
      _builder.append("> findByEnableId(String id);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("public Response delete(String id);");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public Response deletes(List<String> ids);");
      _builder.newLine();
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  public static CharSequence CrudServiceImpl(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      final String basePackageName = project.getRoot();
      String klassType = StringExtensions.toFirstUpper(record.getName());
      String _firstUpper = StringExtensions.toFirstUpper(record.getName());
      String daoType = (_firstUpper + "Repository");
      String oldInfo = (("old" + klassType) + "Info");
      String info = (klassType + "Info");
      String[] _split = project.getRoot().split("\\.");
      int _length = project.getRoot().split("\\.").length;
      int _minus = (_length - 2);
      final String commonPackageName = IterableExtensions.join(((List<String>)Conversions.doWrapArray(_split)).subList(0, _minus), ".");
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      String _firstLower = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("import java.util.List;");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("import java.util.Map;");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("import org.springframework.beans.factory.annotation.Autowired;");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("import org.springframework.data.domain.Page;");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("import org.springframework.data.domain.Sort;");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("import org.springframework.data.domain.Sort.Order;");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("import org.springframework.data.domain.PageRequest;");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("import org.springframework.data.jpa.domain.Specification;");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("import org.springframework.stereotype.Service;");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("import ");
      _builder.append(commonPackageName, "\t\t");
      _builder.append(".common.DynamicSpecifications;");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("import ");
      _builder.append(commonPackageName, "\t\t");
      _builder.append(".common.Merger;");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("import ");
      _builder.append(commonPackageName, "\t\t");
      _builder.append(".common.SearchFilter;");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("import ");
      _builder.append(commonPackageName, "\t\t");
      _builder.append(".common.YjBoon;");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("import ");
      _builder.append(commonPackageName, "\t\t");
      _builder.append(".common.vo.DataResponse;");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("import ");
      _builder.append(commonPackageName, "\t\t");
      _builder.append(".common.vo.Response;");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("import ");
      _builder.append(commonPackageName, "\t\t");
      _builder.append(".common.vo.TableResult;");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("@Service");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("public class ");
      _builder.append(klassType, "\t\t");
      _builder.append("CrudServiceImpl implements ");
      _builder.append(klassType, "\t\t");
      _builder.append("CrudService{");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("@Autowired");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("private ");
      _builder.append(klassType, "\t\t\t");
      _builder.append("Repository ");
      String _firstLower_1 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_1, "\t\t\t");
      _builder.append("Repository;");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("@Override");
      _builder.newLine();
      _builder.append("\t\t\t  ");
      _builder.append("public List<");
      _builder.append(klassType, "\t\t\t  ");
      _builder.append("> findAll(Specification<");
      _builder.append(klassType, "\t\t\t  ");
      _builder.append("> spec) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t\t   \t    ");
      _builder.append("return ");
      String _firstLower_2 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_2, "\t\t\t   \t    ");
      _builder.append("Repository.findAll(spec);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t\t   ");
      _builder.append("}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("@Override");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("public TableResult<List<");
      _builder.append(klassType, "\t\t    ");
      _builder.append(">> findAll(Integer pageNo,Integer pageSize, Map<String, String> queryMap) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("List<SearchFilter> searchFilters = SearchFilter.fromQueryMap(queryMap, ");
      _builder.append(klassType, "\t\t    \t");
      _builder.append(".class);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("searchFilters.add(new SearchFilter(\"enable\", SearchFilter.Operator.EQ,true));");
      _builder.newLine();
      _builder.append("\t\t    \t");
      _builder.append("PageRequest pageRequest = PageRequest.of(pageNo-1, pageSize, Sort.by(Order.desc(\"id\")));");
      _builder.newLine();
      _builder.append("\t\t    \t");
      _builder.append("Specification<");
      _builder.append(klassType, "\t\t    \t");
      _builder.append("> spec = DynamicSpecifications.bySearchFilter(searchFilters, ");
      _builder.append(klassType, "\t\t    \t");
      _builder.append(".class);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("Page<");
      _builder.append(klassType, "\t\t    \t");
      _builder.append("> ");
      String _firstLower_3 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_3, "\t\t    \t");
      _builder.append("s = ");
      String _firstLower_4 = StringExtensions.toFirstLower(daoType);
      _builder.append(_firstLower_4, "\t\t    \t");
      _builder.append(".findAll(spec, pageRequest);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("TableResult<List<");
      _builder.append(klassType, "\t\t    \t");
      _builder.append(">> tableResult = new TableResult<List<");
      _builder.append(klassType, "\t\t    \t");
      _builder.append(">>();");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("tableResult.setPageNo(");
      String _firstLower_5 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_5, "\t\t    \t");
      _builder.append("s.getNumber()+1);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("tableResult.setPageSize(");
      String _firstLower_6 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_6, "\t\t    \t");
      _builder.append("s.getSize());");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("tableResult.setTotalCount(");
      String _firstLower_7 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_7, "\t\t    \t");
      _builder.append("s.getTotalElements());");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("tableResult.setTotalPage(");
      String _firstLower_8 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_8, "\t\t    \t");
      _builder.append("s.getTotalPages());");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("tableResult.setData(");
      String _firstLower_9 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_9, "\t\t    \t");
      _builder.append("s.getContent());");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("return tableResult;");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("@Override");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("public DataResponse<");
      _builder.append(klassType, "\t\t    ");
      _builder.append("> save(");
      _builder.append(klassType, "\t\t    ");
      _builder.append(" ");
      String _firstLower_10 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_10, "\t\t    ");
      _builder.append(") {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t         ");
      _builder.append(klassType, "\t\t         ");
      _builder.append(" saveInfo;");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t         ");
      _builder.append("if(YjBoon.isEmpty(");
      String _firstLower_11 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_11, "\t\t         ");
      _builder.append(".getId())){");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t         \t");
      String _firstLower_12 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_12, "\t\t         \t");
      _builder.append(".setEnable(true);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t         \t  ");
      _builder.append("saveInfo= ");
      String _firstLower_13 = StringExtensions.toFirstLower(daoType);
      _builder.append(_firstLower_13, "\t\t         \t  ");
      _builder.append(".save(");
      String _firstLower_14 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_14, "\t\t         \t  ");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t         ");
      _builder.append("}else{");
      _builder.newLine();
      _builder.append("\t\t            ");
      _builder.append(klassType, "\t\t            ");
      _builder.append(" ");
      _builder.append(oldInfo, "\t\t            ");
      _builder.append(" = ");
      String _firstLower_15 = StringExtensions.toFirstLower(daoType);
      _builder.append(_firstLower_15, "\t\t            ");
      _builder.append(".findByIdAndEnableIsTrue(");
      String _firstLower_16 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_16, "\t\t            ");
      _builder.append(".getId());");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t            ");
      String _firstLower_17 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_17, "\t\t            ");
      _builder.append(" = Merger.mergeNotNullToFirst(");
      _builder.append(oldInfo, "\t\t            ");
      _builder.append(", ");
      String _firstLower_18 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_18, "\t\t            ");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t            ");
      _builder.append("saveInfo= ");
      String _firstLower_19 = StringExtensions.toFirstLower(daoType);
      _builder.append(_firstLower_19, "\t\t            ");
      _builder.append(".save(");
      String _firstLower_20 = StringExtensions.toFirstLower(klassType);
      _builder.append(_firstLower_20, "\t\t            ");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t         ");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t\t         ");
      _builder.append("if(YjBoon.isEmpty(saveInfo)){");
      _builder.newLine();
      _builder.append("\t\t            ");
      _builder.append("return new DataResponse<>(\"-1\",\"error\");");
      _builder.newLine();
      _builder.append("\t\t         ");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t\t        ");
      _builder.append("return new DataResponse<>(\"0\",\"OK\",saveInfo);");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("@Override");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("public DataResponse<");
      _builder.append(klassType, "\t\t    ");
      _builder.append("> findByEnableId(String id){");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append(klassType, "\t\t    \t");
      _builder.append(" ");
      _builder.append(info, "\t\t    \t");
      _builder.append("=");
      String _firstLower_21 = StringExtensions.toFirstLower(daoType);
      _builder.append(_firstLower_21, "\t\t    \t");
      _builder.append(".findByIdAndEnableIsTrue(id);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("if(YjBoon.isEmpty(");
      _builder.append(info, "\t\t    \t");
      _builder.append(")){");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t\t");
      _builder.append("return new DataResponse<>(\"-1\",\"error\");");
      _builder.newLine();
      _builder.append("\t\t    \t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t\t    \t");
      _builder.append("return new DataResponse<>(\"0\",\"OK\",");
      _builder.append(info, "\t\t    \t");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    ");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("@Override");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("public Response delete(String id) {");
      _builder.newLine();
      _builder.append("\t\t         ");
      _builder.append("Integer res=");
      String _firstLower_22 = StringExtensions.toFirstLower(daoType);
      _builder.append(_firstLower_22, "\t\t         ");
      _builder.append(".updateEnableStatus(id);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t         ");
      _builder.append("if(YjBoon.isEmpty(res)){");
      _builder.newLine();
      _builder.append("\t\t         \t");
      _builder.append("return new DataResponse<>(\"-1\",\"删除失败\");");
      _builder.newLine();
      _builder.append("\t\t         ");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t\t       ");
      _builder.append("return new DataResponse<>(\"0\",\"OK\",res);");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("@Override");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("public Response deletes(List<String> ids) {");
      _builder.newLine();
      _builder.append("\t\t    \t");
      _builder.append("Integer res=");
      String _firstLower_23 = StringExtensions.toFirstLower(daoType);
      _builder.append(_firstLower_23, "\t\t    \t");
      _builder.append(".updateEnableStatusBacth(ids);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t    \t");
      _builder.append("if(res==ids.size()){");
      _builder.newLine();
      _builder.append("\t\t    \t\t");
      _builder.append("return new DataResponse<>(\"0\",\"OK\",res);");
      _builder.newLine();
      _builder.append("\t\t    \t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t\t    \t");
      _builder.append("return new DataResponse<>(\"-1\",\"删除失败\");");
      _builder.newLine();
      _builder.append("\t\t    ");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  public static CharSequence entity(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      final String basePackageName = project.getRoot();
      String klassType = StringExtensions.toFirstUpper(record.getName());
      String packageName = StringExtensions.toFirstLower(record.getName());
      String beanName = StringExtensions.toFirstLower(record.getName());
      String[] _split = project.getRoot().split("\\.");
      int _length = project.getRoot().split("\\.").length;
      int _minus = (_length - 2);
      final String commonPackageName = IterableExtensions.join(((List<String>)Conversions.doWrapArray(_split)).subList(0, _minus), 
        ".");
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      _builder.append(packageName);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("import java.util.List;");
      _builder.newLine();
      _builder.append("import java.util.Date;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import javax.persistence.Column;");
      _builder.newLine();
      _builder.append("import javax.persistence.Entity;");
      _builder.newLine();
      _builder.append("import javax.persistence.FetchType;");
      _builder.newLine();
      _builder.append("import javax.persistence.GeneratedValue;");
      _builder.newLine();
      _builder.append("import javax.persistence.GenerationType;");
      _builder.newLine();
      _builder.append("import javax.persistence.Id;");
      _builder.newLine();
      _builder.append("import javax.persistence.JoinColumn;");
      _builder.newLine();
      _builder.append("import javax.persistence.ManyToOne;");
      _builder.newLine();
      _builder.append("import javax.persistence.OneToMany;");
      _builder.newLine();
      _builder.append("import javax.persistence.OneToOne;");
      _builder.newLine();
      _builder.append("import javax.persistence.EntityListeners;");
      _builder.newLine();
      _builder.append("import javax.validation.constraints.NotNull;");
      _builder.newLine();
      _builder.append("import javax.validation.constraints.Pattern;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import org.hibernate.annotations.GenericGenerator;");
      _builder.newLine();
      _builder.append("import org.hibernate.annotations.ManyToAny;");
      _builder.newLine();
      _builder.append("import org.hibernate.annotations.NotFound;");
      _builder.newLine();
      _builder.append("import org.hibernate.annotations.NotFoundAction;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import org.springframework.data.annotation.CreatedDate;");
      _builder.newLine();
      _builder.append("import org.springframework.data.annotation.LastModifiedDate;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import org.springframework.data.annotation.Transient;");
      _builder.newLine();
      _builder.append("import org.springframework.format.annotation.DateTimeFormat;");
      _builder.newLine();
      _builder.append("import com.fasterxml.jackson.annotation.JsonFormat;");
      _builder.newLine();
      _builder.append("import org.springframework.data.jpa.domain.support.AuditingEntityListener;");
      _builder.newLine();
      _builder.append("import com.fasterxml.jackson.annotation.JsonIgnoreProperties;");
      _builder.newLine();
      {
        for(final Field f : fields) {
          {
            String _keyType = f.getKeyType();
            boolean _equals = Objects.equal(_keyType, "M21");
            if (_equals) {
              _builder.append("import ");
              _builder.append(basePackageName);
              _builder.append(".");
              String _firstLower = StringExtensions.toFirstLower(f.javaType());
              _builder.append(_firstLower);
              _builder.append(".");
              String _javaType = f.javaType();
              _builder.append(_javaType);
              _builder.append(";");
              _builder.newLineIfNotEmpty();
            }
          }
          {
            String _keyType_1 = f.getKeyType();
            boolean _equals_1 = Objects.equal(_keyType_1, "12M");
            if (_equals_1) {
              _builder.append("import ");
              _builder.append(basePackageName);
              _builder.append(".");
              String _firstLower_1 = StringExtensions.toFirstLower(f.javaType());
              _builder.append(_firstLower_1);
              _builder.append(".");
              String _javaType_1 = f.javaType();
              _builder.append(_javaType_1);
              _builder.append(";");
              _builder.newLineIfNotEmpty();
            }
          }
          {
            String _keyType_2 = f.getKeyType();
            boolean _equals_2 = Objects.equal(_keyType_2, "121");
            if (_equals_2) {
              _builder.append("import ");
              _builder.append(basePackageName);
              _builder.append(".");
              String _firstLower_2 = StringExtensions.toFirstLower(f.javaType());
              _builder.append(_firstLower_2);
              _builder.append(".");
              String _javaType_2 = f.javaType();
              _builder.append(_javaType_2);
              _builder.append(";");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".Validators;");
      _builder.newLineIfNotEmpty();
      _builder.append("import lombok.Data;");
      _builder.newLine();
      _builder.append("import lombok.ToString;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("@Data");
      _builder.newLine();
      _builder.append("@ToString(exclude={");
      {
        for(final Field f_1 : fields) {
          {
            if ((Objects.equal(f_1.getKeyType(), "M21") || Objects.equal(f_1.getKeyType(), "121"))) {
              _builder.append("\"");
              String _name = f_1.getName();
              _builder.append(_name);
              _builder.append("\",");
            }
          }
        }
      }
      _builder.append("}) ");
      _builder.newLineIfNotEmpty();
      _builder.append("@Entity");
      _builder.newLine();
      _builder.append("@JsonIgnoreProperties(ignoreUnknown = true, value = {\"hibernateLazyInitializer\", \"handler\", \"fieldHandler\"})");
      _builder.newLine();
      _builder.append("@EntityListeners(AuditingEntityListener.class)");
      _builder.newLine();
      _builder.append("public class ");
      _builder.append(klassType);
      _builder.append(" {");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      {
        for(final Field f_2 : fields) {
          _builder.newLine();
          _builder.append("/**");
          String _doc = f_2.getDoc();
          _builder.append(_doc);
          _builder.append("**/");
          _builder.newLineIfNotEmpty();
          {
            String _keyType_3 = f_2.getKeyType();
            boolean _equals_3 = Objects.equal(_keyType_3, "P");
            if (_equals_3) {
              _builder.append("@Id");
              _builder.newLine();
              _builder.append("@GenericGenerator(name=\"system-uuid\", strategy=\"uuid\") //这个是hibernate的注解/生成32位UUID");
              _builder.newLine();
              _builder.append("@GeneratedValue(generator=\"system-uuid\")");
              _builder.newLine();
              _builder.append("@Column(length = 32)");
              _builder.newLine();
            } else {
              String _keyType_4 = f_2.getKeyType();
              boolean _equals_4 = Objects.equal(_keyType_4, "M21");
              if (_equals_4) {
                _builder.append("@JsonIgnoreProperties(ignoreUnknown = true, value = {\"");
                _builder.append(beanName);
                _builder.append("s\"})");
                _builder.newLineIfNotEmpty();
                _builder.append("@ManyToOne(fetch=FetchType.EAGER,optional=false)");
                _builder.newLine();
                _builder.append("@NotFound(action= NotFoundAction.IGNORE)");
                _builder.newLine();
              } else {
                String _keyType_5 = f_2.getKeyType();
                boolean _equals_5 = Objects.equal(_keyType_5, "12M");
                if (_equals_5) {
                  _builder.append("@Transient");
                  _builder.newLine();
                  _builder.append("@JsonIgnoreProperties(ignoreUnknown = true, value = {\"");
                  _builder.append(beanName);
                  _builder.append("\"})");
                  _builder.newLineIfNotEmpty();
                  _builder.append("@OneToMany(fetch=FetchType.LAZY,mappedBy=\"");
                  _builder.append(beanName);
                  _builder.append("\",orphanRemoval=false)");
                  _builder.newLineIfNotEmpty();
                  _builder.append("@NotFound(action= NotFoundAction.IGNORE)");
                  _builder.newLine();
                } else {
                  String _keyType_6 = f_2.getKeyType();
                  boolean _equals_6 = Objects.equal(_keyType_6, "121");
                  if (_equals_6) {
                    _builder.append("@OneToOne(fetch=FetchType.EAGER)");
                    _builder.newLine();
                    _builder.append("@NotFound(action= NotFoundAction.IGNORE)");
                    _builder.newLine();
                  }
                }
              }
            }
          }
          {
            String _type = f_2.getType();
            boolean _equals_7 = Objects.equal(_type, "date");
            if (_equals_7) {
              _builder.append("@DateTimeFormat(pattern = \"yyyy-MM-dd\")");
              _builder.newLine();
              _builder.append("@JsonFormat(pattern=\"yyyy-MM-dd\",timezone = \"GMT+8\")");
              _builder.newLine();
              {
                boolean _contains = f_2.getName().contains("createTime");
                if (_contains) {
                  _builder.append("@CreatedDate");
                }
              }
              _builder.newLineIfNotEmpty();
              {
                boolean _contains_1 = f_2.getName().contains("modifyTime");
                if (_contains_1) {
                  _builder.append("@LastModifiedDate");
                }
              }
              _builder.newLineIfNotEmpty();
            } else {
              String _type_1 = f_2.getType();
              boolean _equals_8 = Objects.equal(_type_1, "datetime");
              if (_equals_8) {
                _builder.append("@DateTimeFormat(pattern = \"yyyy-MM-dd HH:mm:ss\")");
                _builder.newLine();
                _builder.append("@JsonFormat(pattern=\"yyyy-MM-dd HH:mm:ss\",timezone = \"GMT+8\")");
                _builder.newLine();
                {
                  boolean _contains_2 = f_2.getName().contains("createTime");
                  if (_contains_2) {
                    _builder.append("@CreatedDate");
                  }
                }
                _builder.newLineIfNotEmpty();
                {
                  boolean _contains_3 = f_2.getName().contains("modifyTime");
                  if (_contains_3) {
                    _builder.append("@LastModifiedDate");
                  }
                }
                _builder.newLineIfNotEmpty();
              }
            }
          }
          {
            boolean _requried = Heyang2019.toValid(f_2.getValid()).getRequried();
            boolean _equals_9 = (_requried == true);
            if (_equals_9) {
              {
                String _javaType_3 = f_2.javaType();
                boolean _equals_10 = Objects.equal(_javaType_3, "List");
                if (_equals_10) {
                  _builder.append("@NotEmpty(message =\"");
                  String _doc_1 = f_2.getDoc();
                  _builder.append(_doc_1);
                  _builder.append("列表不能为空\")");
                  _builder.newLineIfNotEmpty();
                }
              }
              _builder.append("@NotNull(message =\"");
              String _doc_2 = f_2.getDoc();
              _builder.append(_doc_2);
              _builder.append("不能为空\")");
              _builder.newLineIfNotEmpty();
            }
          }
          {
            String _valid = Heyang2019.toValid(f_2.getValid()).getValid();
            boolean _equals_11 = Objects.equal(_valid, "cname");
            if (_equals_11) {
              _builder.append("@Pattern(regexp = Validators.REGEX_CHINESE_LENGTH ,message = \"姓名应当使用汉字！并且长度应当在2至8个汉字之间！\")");
              _builder.newLine();
            } else {
              String _valid_1 = Heyang2019.toValid(f_2.getValid()).getValid();
              boolean _equals_12 = Objects.equal(_valid_1, "ename");
              if (_equals_12) {
                _builder.append("@Pattern(regexp = Validators.REGEX_USERNAME_PLUS ,message = \"用户名应当使用英文数字！并且长度应当在4至10个汉字之间！\")");
                _builder.newLine();
              } else {
                String _valid_2 = Heyang2019.toValid(f_2.getValid()).getValid();
                boolean _equals_13 = Objects.equal(_valid_2, "name");
                if (_equals_13) {
                  _builder.append("@Pattern(regexp = Validators.REGEX_CHINESE_OR_ENGLISH_OR_NUMBER ,message = \"名称应当使用汉字英文数字！并且长度应当在2至40个汉字之间！\")");
                  _builder.newLine();
                } else {
                  String _valid_3 = Heyang2019.toValid(f_2.getValid()).getValid();
                  boolean _equals_14 = Objects.equal(_valid_3, "address");
                  if (_equals_14) {
                    _builder.append("@Pattern(regexp = Validators.REGEX_CHINESE_OR_ENGLISH_OR_NUMBER ,message = \"地址应当使用中文、英文、数字！并且长度应当在2至40个汉字之间！\")");
                    _builder.newLine();
                  } else {
                    String _valid_4 = Heyang2019.toValid(f_2.getValid()).getValid();
                    boolean _equals_15 = Objects.equal(_valid_4, "phone");
                    if (_equals_15) {
                      _builder.append("@Pattern(regexp = Validators.REGEX_MOBILE ,message = \"手机号码格式不对！\")");
                      _builder.newLine();
                    } else {
                      String _valid_5 = Heyang2019.toValid(f_2.getValid()).getValid();
                      boolean _equals_16 = Objects.equal(_valid_5, "password");
                      if (_equals_16) {
                        _builder.append("@Pattern(regexp = Validators.REGEX_ENGLISH_OR_NUMBER_LENGTH ,message = \"密码应当为英文、数字，并且长度在6-12位之间！\")");
                        _builder.newLine();
                      } else {
                        String _valid_6 = Heyang2019.toValid(f_2.getValid()).getValid();
                        boolean _equals_17 = Objects.equal(_valid_6, "path");
                        if (_equals_17) {
                          _builder.append("@Pattern(regexp = Validators.REGEX_PATH ,message = \"路径应该格式正确！！\")");
                          _builder.newLine();
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          _builder.append("private ");
          String _javaType_4 = f_2.javaType();
          _builder.append(_javaType_4);
          _builder.append(" ");
          String _firstLower_3 = StringExtensions.toFirstLower(f_2.getName());
          _builder.append(_firstLower_3);
          _builder.append(";");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  public static CharSequence customdao(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      final String basePackageName = project.getRoot();
      String _firstUpper = StringExtensions.toFirstUpper(record.getName());
      String daoType = (_firstUpper + "Repository");
      String packageName = StringExtensions.toFirstLower(record.getName());
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      _builder.append(packageName);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("import java.util.List;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("interface Customized");
      _builder.append(daoType);
      _builder.append(" {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  public static CharSequence customdaoimpl(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      final String basePackageName = project.getRoot();
      String _firstUpper = StringExtensions.toFirstUpper(record.getName());
      String daoType = (_firstUpper + "Repository");
      String packageName = StringExtensions.toFirstLower(record.getName());
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      _builder.append(packageName);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("import java.util.List;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import org.springframework.beans.factory.annotation.Autowired;");
      _builder.newLine();
      _builder.append("import org.springframework.jdbc.core.BeanPropertyRowMapper;");
      _builder.newLine();
      _builder.append("import org.springframework.jdbc.core.JdbcTemplate;");
      _builder.newLine();
      _builder.append("import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("class Customized");
      _builder.append(daoType);
      _builder.append("Impl implements Customized");
      _builder.append(daoType);
      _builder.append("  {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("    ");
      _builder.append("@Autowired");
      _builder.newLine();
      _builder.append("    ");
      _builder.append("private JdbcTemplate jdbcTemplate;");
      _builder.newLine();
      _builder.append("    ");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  public static CharSequence dao(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      final String basePackageName = project.getRoot();
      String beanType = StringExtensions.toFirstUpper(record.getName());
      String _firstUpper = StringExtensions.toFirstUpper(record.getName());
      String daoType = (_firstUpper + "Repository");
      String packageName = StringExtensions.toFirstLower(record.getName());
      String tableName = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, record.getName());
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      String _firstLower = StringExtensions.toFirstLower(packageName);
      _builder.append(_firstLower);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("import java.util.List;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import javax.transaction.Transactional;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import org.springframework.data.jpa.repository.JpaRepository;");
      _builder.newLine();
      _builder.append("import org.springframework.data.jpa.repository.JpaSpecificationExecutor;");
      _builder.newLine();
      _builder.append("import org.springframework.data.jpa.repository.Modifying;");
      _builder.newLine();
      _builder.append("import org.springframework.data.jpa.repository.Query;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("public interface ");
      _builder.append(daoType);
      _builder.append(" extends JpaRepository<");
      _builder.append(beanType);
      _builder.append(", String>, JpaSpecificationExecutor<");
      _builder.append(beanType);
      _builder.append(">, Customized");
      _builder.append(daoType);
      _builder.append("{");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      {
        for(final Field f : fields) {
          {
            String _keyType = f.getKeyType();
            boolean _equals = Objects.equal(_keyType, "U");
            if (_equals) {
              _builder.append("\t");
              _builder.append("public ");
              _builder.append(beanType, "\t");
              _builder.append(" findBy");
              String _firstUpper_1 = StringExtensions.toFirstUpper(f.getName());
              _builder.append(_firstUpper_1, "\t");
              _builder.append("AndEnableIsTrue(");
              String _javaType = f.javaType();
              _builder.append(_javaType, "\t");
              _builder.append(" ");
              String _name = f.getName();
              _builder.append(_name, "\t");
              _builder.append(");");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public ");
      _builder.append(beanType, "\t");
      _builder.append(" findByIdAndEnableIsTrue(String id);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@Transactional");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@Modifying");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@Query(value = \"update ");
      _builder.append(tableName, "\t");
      _builder.append(" set enable = 0 where id = ?1\",nativeQuery = true)");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("public Integer updateEnableStatus(String id);");
      _builder.newLine();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@Transactional");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@Modifying");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@Query(value = \"update ");
      _builder.append(tableName, "\t");
      _builder.append(" set enable = 0 where id in (:ids)\",nativeQuery = true)");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("public Integer updateEnableStatusBacth(List<String> ids);");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("// add more ...");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  public static CharSequence controller(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      final String basePackageName = project.getRoot();
      String[] _split = project.getRoot().split("\\.");
      int _length = project.getRoot().split("\\.").length;
      int _minus = (_length - 2);
      final String commonPackageName = IterableExtensions.join(((List<String>)Conversions.doWrapArray(_split)).subList(0, _minus), ".");
      String beanType = StringExtensions.toFirstUpper(record.getName());
      String _firstUpper = StringExtensions.toFirstUpper(record.getName());
      String serviceType = (_firstUpper + "Service");
      String _firstUpper_1 = StringExtensions.toFirstUpper(record.getName());
      String klassType = (_firstUpper_1 + "Controller");
      String packageName = StringExtensions.toFirstLower(record.getName());
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      _builder.append(packageName);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("import java.util.List;");
      _builder.newLine();
      _builder.append("import java.util.Map;");
      _builder.newLine();
      _builder.append("import java.util.Optional;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import javax.servlet.http.HttpServletRequest;");
      _builder.newLine();
      _builder.append("import javax.validation.Valid;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import io.swagger.annotations.Api;");
      _builder.newLine();
      _builder.append("import io.swagger.annotations.ApiImplicitParam;");
      _builder.newLine();
      _builder.append("import io.swagger.annotations.ApiImplicitParams;");
      _builder.newLine();
      _builder.append("import io.swagger.annotations.ApiOperation;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import org.slf4j.Logger;");
      _builder.newLine();
      _builder.append("import org.slf4j.LoggerFactory;");
      _builder.newLine();
      _builder.append("import org.springframework.beans.factory.annotation.Autowired;");
      _builder.newLine();
      _builder.append("import org.springframework.data.domain.Page;");
      _builder.newLine();
      _builder.append("import org.springframework.data.domain.PageRequest;");
      _builder.newLine();
      _builder.append("import org.springframework.data.domain.Sort;");
      _builder.newLine();
      _builder.append("import org.springframework.data.domain.Sort.Order;");
      _builder.newLine();
      _builder.append("import org.springframework.data.jpa.domain.Specification;");
      _builder.newLine();
      _builder.append("import org.springframework.validation.BindingResult;");
      _builder.newLine();
      _builder.append("import org.springframework.validation.DataBinder;");
      _builder.newLine();
      _builder.append("import org.springframework.validation.ObjectError;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.InitBinder;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.PathVariable;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.RequestBody;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.RequestMapping;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.RequestMethod;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.RequestParam;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.RestController;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.DynamicSpecifications;");
      _builder.newLineIfNotEmpty();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.SearchFilter;");
      _builder.newLineIfNotEmpty();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.vo.DataResponse;");
      _builder.newLineIfNotEmpty();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.vo.Response;");
      _builder.newLineIfNotEmpty();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.vo.TableResult;");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("@Api(\"");
      String _label = record.getLabel();
      _builder.append(_label);
      _builder.append("管理接口\")");
      _builder.newLineIfNotEmpty();
      _builder.append("@RestController");
      _builder.newLine();
      _builder.append("@RequestMapping(\"/controller/v1/");
      String _firstLower = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower);
      _builder.append("\")");
      _builder.newLineIfNotEmpty();
      _builder.append("public class ");
      _builder.append(klassType);
      _builder.append(" {");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("private static final Logger LOGGER = LoggerFactory.getLogger(");
      _builder.append(klassType, "\t");
      _builder.append(".class);");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@Autowired");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("private ");
      _builder.append(serviceType, "\t");
      _builder.append(" ");
      String _firstLower_1 = StringExtensions.toFirstLower(serviceType);
      _builder.append(_firstLower_1, "\t");
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@ApiOperation(value = \"查询");
      String _label_1 = record.getLabel();
      _builder.append(_label_1, "\t");
      _builder.append("信息\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/\", method = RequestMethod.GET)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public DataResponse<List<");
      _builder.append(beanType, "\t");
      _builder.append(">> search(HttpServletRequest request) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("Map<String, String[]> requestParameterMap = request.getParameterMap();");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("List<SearchFilter> searchFilters = SearchFilter.from(requestParameterMap, ");
      _builder.append(klassType, "\t\t");
      _builder.append(".class);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("searchFilters.add(new SearchFilter(\"enable\", SearchFilter.Operator.EQ, true));");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("Specification<");
      _builder.append(beanType, "\t\t");
      _builder.append("> spec = DynamicSpecifications.bySearchFilter(searchFilters, ");
      _builder.append(beanType, "\t\t");
      _builder.append(".class);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("List<");
      _builder.append(beanType, "\t\t");
      _builder.append("> ");
      String _firstLower_2 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_2, "\t\t");
      _builder.append("s = ");
      String _firstLower_3 = StringExtensions.toFirstLower(serviceType);
      _builder.append(_firstLower_3, "\t\t");
      _builder.append(".findAll(spec);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("return new DataResponse<List<");
      _builder.append(beanType, "\t\t");
      _builder.append(">>(\"0\", \"查询成功!\", ");
      String _firstLower_4 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_4, "\t\t");
      _builder.append("s);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@ApiOperation(value = \"分页查询");
      String _label_2 = record.getLabel();
      _builder.append(_label_2, "\t");
      _builder.append("\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@ApiImplicitParams({");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("@ApiImplicitParam(name = \"pageNo\",value = \"页码\",paramType =\"query\", required = false,dataType = \"Integer\",defaultValue = \"1\"),");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("@ApiImplicitParam(name = \"pageSize\",value = \"每页显示条数\",paramType =\"query\",required = false,dataType = \"Integer\",defaultValue = \"20\"),");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("@ApiImplicitParam(name = \"queryMap\",value = \"查询条件\",paramType =\"body\",required = false,dataType = \"Map\")");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("})");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/page\", method = RequestMethod.POST)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public DataResponse<TableResult<List<");
      _builder.append(beanType, "\t");
      _builder.append(">>> page(");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@RequestParam(value = \"pageNo\", required = false, defaultValue = \"1\") Integer pageNo,");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestParam(value = \"pageSize\", required = false, defaultValue = \"20\") Integer pageSize,");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestBody Map<String, String> queryMap) {");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("TableResult<List<");
      _builder.append(beanType, "\t\t");
      _builder.append(">> tableResult = ");
      String _firstLower_5 = StringExtensions.toFirstLower(serviceType);
      _builder.append(_firstLower_5, "\t\t");
      _builder.append(".findAll(pageNo, pageSize,queryMap);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("return new DataResponse<TableResult<List<");
      _builder.append(beanType, "\t\t");
      _builder.append(">>>(\"0\", \"查询成功!\", tableResult);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("}\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@ApiOperation(value = \"新建 ");
      String _label_3 = record.getLabel();
      _builder.append(_label_3, "\t");
      _builder.append("信息\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@ApiImplicitParam(name = \"");
      String _firstLower_6 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_6, "\t");
      _builder.append("\",value = \"");
      String _label_4 = record.getLabel();
      _builder.append(_label_4, "\t");
      _builder.append("对象\", required = true, paramType = \"body\",dataType = \"");
      _builder.append(beanType, "\t");
      _builder.append("\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/\", method = RequestMethod.POST)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public DataResponse<");
      _builder.append(beanType, "\t");
      _builder.append("> create(@RequestBody @Valid ");
      _builder.append(beanType, "\t");
      _builder.append(" ");
      String _firstLower_7 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_7, "\t");
      _builder.append(", BindingResult result) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("LOGGER.debug(\"add ");
      String _firstLower_8 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_8, "\t\t");
      _builder.append(":  {}\", ");
      String _firstLower_9 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_9, "\t\t");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("if (result.hasErrors()) {");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("StringBuffer sb = new StringBuffer();");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("for (ObjectError msg : result.getAllErrors())");
      _builder.newLine();
      _builder.append("\t\t\t\t");
      _builder.append("sb.append(msg.getDefaultMessage()).append(\" \");");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("return new DataResponse<");
      _builder.append(beanType, "\t\t\t");
      _builder.append(">(\"-1\", sb.toString());");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t    ");
      _builder.append("return ");
      String _firstLower_10 = StringExtensions.toFirstLower(serviceType);
      _builder.append(_firstLower_10, "\t    ");
      _builder.append(".save(");
      String _firstLower_11 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_11, "\t    ");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@ApiOperation(value = \"编辑 ");
      String _label_5 = record.getLabel();
      _builder.append(_label_5, "\t");
      _builder.append("信息\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@ApiImplicitParam(name = \"");
      String _firstLower_12 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_12, "\t");
      _builder.append("\",value = \"");
      String _label_6 = record.getLabel();
      _builder.append(_label_6, "\t");
      _builder.append("对象\", required = true, paramType = \"body\",dataType = \"");
      _builder.append(beanType, "\t");
      _builder.append("\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/\", method = RequestMethod.PUT)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public DataResponse<");
      _builder.append(beanType, "\t");
      _builder.append("> update(@RequestBody @Valid ");
      _builder.append(beanType, "\t");
      _builder.append(" ");
      String _firstLower_13 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_13, "\t");
      _builder.append(", BindingResult result) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("LOGGER.debug(\"add ");
      String _firstLower_14 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_14, "\t\t");
      _builder.append(":  {}\", ");
      String _firstLower_15 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_15, "\t\t");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("if (result.hasErrors()) {");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("StringBuffer sb = new StringBuffer();");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("for (ObjectError msg : result.getAllErrors())");
      _builder.newLine();
      _builder.append("\t\t\t\t");
      _builder.append("sb.append(msg.getDefaultMessage()).append(\" \");");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("return new DataResponse<");
      _builder.append(beanType, "\t\t\t");
      _builder.append(">(\"-1\", sb.toString());");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t    ");
      _builder.append("return ");
      String _firstLower_16 = StringExtensions.toFirstLower(serviceType);
      _builder.append(_firstLower_16, "\t    ");
      _builder.append(".save(");
      String _firstLower_17 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_17, "\t    ");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@ApiOperation(value = \"根据ID获取 ");
      String _label_7 = record.getLabel();
      _builder.append(_label_7, "\t");
      _builder.append("信息\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@ApiImplicitParam(name=\"id\",value = \" ");
      String _label_8 = record.getLabel();
      _builder.append(_label_8, "\t");
      _builder.append("ID\",required = true,paramType = \"path\",dataType = \"String\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/{id}\", method = RequestMethod.GET)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public DataResponse<");
      _builder.append(beanType, "\t");
      _builder.append("> get(@PathVariable(\"id\") String id) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("LOGGER.debug(\"id:  {}\", id);");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("return ");
      String _firstLower_18 = StringExtensions.toFirstLower(serviceType);
      _builder.append(_firstLower_18, "\t\t");
      _builder.append(".findByEnableId(id);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@ApiOperation(value = \"根据ID删除 ");
      String _label_9 = record.getLabel();
      _builder.append(_label_9, "\t");
      _builder.append("信息\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@ApiImplicitParam(name=\"id\",value = \" ");
      String _label_10 = record.getLabel();
      _builder.append(_label_10, "\t");
      _builder.append("ID\",required = true,paramType = \"path\",dataType = \"String\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/{id}\", method = RequestMethod.DELETE)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public Response delete(@PathVariable(\"id\") String id) {");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("LOGGER.debug(\"id:  {}\", id);");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("return ");
      String _firstLower_19 = StringExtensions.toFirstLower(serviceType);
      _builder.append(_firstLower_19, "\t\t");
      _builder.append(".delete(id);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@ApiOperation(value = \"根据ID批量删除");
      String _label_11 = record.getLabel();
      _builder.append(_label_11, "\t");
      _builder.append("信息\")");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@ApiImplicitParam(name =\"ids\",value = \"id集合\",required = true,paramType = \"body\",dataType = \"List\")");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/deletes\", method = RequestMethod.POST)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public Response ");
      String _firstLower_20 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_20, "\t");
      _builder.append("Deletes(@RequestBody List<String> ids) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("LOGGER.debug(\"ids:  {}\", ids);");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("return ");
      String _firstLower_21 = StringExtensions.toFirstLower(serviceType);
      _builder.append(_firstLower_21, "\t\t");
      _builder.append(".deletes(ids);");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  public static CharSequence restcli(final Project project, final Record record, final List<Field> fields) {
    CharSequence _xblockexpression = null;
    {
      final String basePackageName = project.getRoot();
      String[] _split = project.getRoot().split("\\.");
      int _length = project.getRoot().split("\\.").length;
      int _minus = (_length - 2);
      final String commonPackageName = IterableExtensions.join(((List<String>)Conversions.doWrapArray(_split)).subList(0, _minus), ".");
      String beanType = StringExtensions.toFirstUpper(record.getName());
      String _firstUpper = StringExtensions.toFirstUpper(record.getName());
      String klassType = (_firstUpper + "Cli");
      String packageName = StringExtensions.toFirstLower(record.getName());
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      _builder.append(basePackageName);
      _builder.append(".");
      _builder.append(packageName);
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("import java.util.List;");
      _builder.newLine();
      _builder.append("import java.util.Map;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import org.springframework.cloud.openfeign.FeignClient;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.PathVariable;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.RequestBody;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.RequestMapping;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.RequestMethod;");
      _builder.newLine();
      _builder.append("import org.springframework.web.bind.annotation.RequestParam;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.vo.DataResponse;");
      _builder.newLineIfNotEmpty();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.vo.Response;");
      _builder.newLineIfNotEmpty();
      _builder.append("import ");
      _builder.append(commonPackageName);
      _builder.append(".common.vo.TableResult;");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.newLine();
      _builder.append("@FeignClient(url = \"${feign.restcli.request.url}/controller/v1/");
      String _firstLower = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower);
      _builder.append("\", name = \"");
      String _firstLower_1 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_1);
      _builder.append("Cli\")");
      _builder.newLineIfNotEmpty();
      _builder.append("public interface ");
      _builder.append(klassType);
      _builder.append(" {");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/\", method = RequestMethod.GET)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public DataResponse<List<");
      _builder.append(beanType, "\t");
      _builder.append(">> all();");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/page\", method = RequestMethod.POST)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public DataResponse<TableResult<List<");
      _builder.append(beanType, "\t");
      _builder.append(">>> page(");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("@RequestParam(value = \"pageNo\", required = false, defaultValue = \"1\") Integer pageNo,");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestParam(value = \"pageSize\", required = false, defaultValue = \"20\") Integer pageSize,");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestBody Map<String, String> queryMap);");
      _builder.newLine();
      _builder.append("\t");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/\", method = RequestMethod.POST)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public Response create(@RequestBody ");
      _builder.append(beanType, "\t");
      _builder.append(" ");
      String _firstLower_2 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_2, "\t");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/\", method = RequestMethod.PUT)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public Response update(@RequestBody ");
      _builder.append(beanType, "\t");
      _builder.append(" ");
      String _firstLower_3 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_3, "\t");
      _builder.append(");");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/{id}\", method = RequestMethod.DELETE)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public Response delete(@PathVariable(\"id\") String id);");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@RequestMapping(value = \"/deletes\", method = RequestMethod.POST)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public Response ");
      String _firstLower_4 = StringExtensions.toFirstLower(beanType);
      _builder.append(_firstLower_4, "\t");
      _builder.append("Deletes(@RequestBody List<String> ids);");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
}
